//
//  VoiceTabbarController.m
//  VoiceShow
//
//  Created by luckyncl on 17/1/6.
//  Copyright © 2017年 luckyncl. All rights reserved.
//

#import "VoiceTabbarController.h"
#import "VoiceNavController.h"
#import "HomeViewController.h"
#import "CircleViewController.h"
#import "MessageViewController.h"
#import "MyViewController.h"
#import "VoiceTabbar.h"
#import "VoiceNavController.h"
@interface VoiceTabbarController ()

@end

@implementation VoiceTabbarController

+ (void)initialize
{
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:11];
    attrs[NSForegroundColorAttributeName] = [UIColor colorWithRed:0.60 green:0.60 blue:0.60 alpha:1.00];
    
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor colorWithRed:0.98 green:0.58 blue:0.50 alpha:1.00];
    
    
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    if ([UIDevice currentDevice].systemVersion.floatValue >= 7) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }

    
    [self setupChildVc:[[HomeViewController alloc] init] title:@"首页" image:@"home" selectedImage:@"home-select"];
    
    [self setupChildVc:[[CircleViewController alloc] init] title:@"圈子" image:@"circle" selectedImage:@"circle-select"];
    
    [self setupChildVc:[[MessageViewController alloc] init] title:@"消息" image:@"msg-select" selectedImage:@"msg"];
    
    

    
    [self setupChildVc:[[MyViewController alloc] init] title:@"我的" image:@"my" selectedImage:@"my-select"];
    
    [self setValue:[[VoiceTabbar alloc] init] forKeyPath:@"tabBar"];
    
}

/**
 *   添加子控制器
 */
- (void)setupChildVc:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    vc.navigationItem.title = title;
    vc.tabBarItem.title = title;

    vc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    VoiceNavController *nav = [[VoiceNavController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
